package com.ruoyi.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.domain.TestUser;
import com.ruoyi.domain.param.StateParam;
import com.ruoyi.mapper.TestUserMapper;
import com.ruoyi.service.ITestUserService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 考试平台用户Service业务层处理
 *
 */
@Service
public class TestUserServiceImpl extends ServiceImpl<TestUserMapper,TestUser> implements ITestUserService
{
    @Autowired
    private TestUserMapper testUserMapper;

    /**
     * 查询考试平台用户
     *
     * @param userId 考试平台用户主键
     * @return 考试平台用户
     */
    @Override
    public TestUser selectTestUserByUserId(Long userId)
    {
        return testUserMapper.selectTestUserByUserId(userId);
    }


    /**
     * 查询学生用户
     *
     * @param userName 用户名
     * @return 考试平台用户
     */
    @Override
    public List<TestUser> getStudents(String userName, @Param("ew") QueryWrapper<TestUser> wrapper) {
        return testUserMapper.getStudents(userName,wrapper);
    }

    @Override
    public List<TestUser> getTeachers(String userName, @Param("ew") QueryWrapper<TestUser> wrapper) {
        return testUserMapper.getTeacher(userName,wrapper);
    }

    @Override
    public List<TestUser> getAdministrators(String userName, @Param("ew") QueryWrapper<TestUser> wrapper) {
        return testUserMapper.getAdministrators(userName,wrapper);
    }

    /**
     * 新增考试平台用户
     *
     * @param testUser 考试平台用户
     */
    @Override
    public int insertTestUser(TestUser testUser)
    {
        testUser.setCreateTime(DateUtils.getNowDate());
        return testUserMapper.insertTestUser(testUser);
    }

    /**
     * 修改考试平台用户
     *
     * @param testUser 考试平台用户
     */
    @Override
    public int updateTestUser(TestUser testUser)
    {
        return testUserMapper.updateTestUser(testUser);
    }

    /**
     * 批量删除考试平台用户
     *
     * @param userIds 需要删除的考试平台用户主键
     */
    @Override
    public int deleteTestUserByUserIds(Long[] userIds)
    {
        return testUserMapper.deleteTestUserByUserIds(userIds);
    }

    /**
     * 删除考试平台用户信息
     *
     * @param userId 考试平台用户主键
     */

    /**
     * 启用考试平台用户信息
     *
     * @param stateParam 某用户状态参数
     */
    @Override
    public int updateStatus(StateParam stateParam) {
        return testUserMapper.updateStatus(stateParam);
    }
}
